home *** CD-ROM | disk | FTP | other *** search
- Path: rain.fr!world-net!cancer
- From: zoccolo@worldnet.fr (Franck ZOCCOLO)
- Newsgroups: comp.lang.c++
- Subject: Re: Casting pointer to member function to pointer to function
- Date: Wed, 20 Mar 96 20:59:14 GMT
- Organization: Association des Joueurs de Baby-Foot (A.J.B.F)
- Message-ID: <4iprqv$onv@aldebaran.sct.fr>
- References: <314CD34A.7DBB@world.std.com>
- NNTP-Posting-Host: nice0-133.sct.fr
- Mime-Version: 1.0
- Content-Type: text/plain; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
- X-Newsreader: News Xpress 2.0 Beta #0
-
- >|Hi all,
- >|
- >|I can't seem to get this to work and can't figure if it's even legal. I
- >|have a global function that takes as an argument a pointer to function.
- >|The pointer to function is defined as
- >|
- >|long (__stdcall *)(void *,unsigned int,unsigned int,long)
- >|
- >|I would like to pass a function that is a member of a class called CGWnd
- >|to this function which would be defined as:
- >|
- >|long (__stdcall CGWnd::*)(void *,unsigned int,unsigned int,long)
- >|
- >|I've tried casting but but MSVC++ gives me an error that effectively
- >|says I can't cast away the function's class membership. Anyone know if
- >|there is a way around this?
- >|
-
- A member function has an hidden parameter (named "this").
- So you can't convert a member function pointer to a "classic" function
- pointer. If you want to do that anyway, you should (I don't know if it works)
- declare your member function as a static member in your class.
-
- |
-
- Franck ZOCCOLO
- Computer Science Student
- E-Mail: zoccolo@essi.fr / zoccolo@worldnet.fr
- WWW : http://www.essi.fr/~zoccolo / http://www.worldnet.fr/~zoccolo
-